home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / blended2 < prev    next >
Encoding:
Text File  |  2000-12-12  |  3.4 KB  |  92 lines

  1. #!/usr/app/bin/perl
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5.  
  6. use Gimp qw(:auto __ N_);
  7. use Gimp::Fu;
  8. use Gimp::Util;
  9.  
  10. #Gimp::set_trace(TRACE_CALL);
  11.  
  12. sub my_innerbevel {
  13.     my ($image, $drawable, $bg_col, $bl1, $bl2, $elev, $depth, $rad_tog) = @_;
  14.     $drawable->has_alpha or die "You can't run this script without an ALPHA CHANNEL!!";
  15.     my $img = gimp_image_new (256, 100, RGB_IMAGE);
  16.     $drawable->image->selection_all;
  17.     $drawable->edit_copy;
  18.     gimp_selection_none ($image);
  19.     if ($rad_tog == 0) {
  20.         my $bg_layer;
  21.         $bg_layer=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1), "Background", 100, NORMAL_MODE);
  22.         gimp_palette_set_background ($bg_col);
  23.         $bg_layer->drawable_fill(BG_IMAGE_FILL);
  24.         $img->add_layer($bg_layer,0);
  25.     }
  26.         $img->resize($drawable->width,$drawable->height, 0, 0);
  27.     my $text1_lay;
  28.     $text1_lay=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1), "Text -1-", 100, NORMAL_MODE);
  29.     $img->add_layer($text1_lay,-1);
  30.     gimp_edit_clear ($text1_lay);
  31.     $text1_lay->edit_paste(0)->floating_sel_anchor;
  32.     $text1_lay->set_preserve_trans(1);
  33.     gimp_palette_set_foreground ($bl1);
  34.     gimp_palette_set_background ($bl2);
  35.     @start = ($text1_lay->width / 2 - 5, 0);
  36.     @end = ($text1_lay->width / 2 + 5, $text1_lay->height);
  37.     gimp_blend ($text1_lay, 0, 0, 0, 100, 0, 0, 0, 2, 0.30, @start, @end);
  38.     my $text2_lay;
  39.     $text2_lay=$text1_lay->copy(1);
  40.     $img->add_layer($text2_lay, -1);
  41.     gimp_palette_set_background ([255, 255, 255]);
  42.     $text2_lay->edit_fill(BG_IMAGE_FILL);
  43.     $text2_lay->set_preserve_trans(0);
  44.     $text1_lay->set_preserve_trans(0);
  45.     plug_in_gauss_rle ($text2_lay, 6, 1, 1);
  46.     plug_in_bump_map ($img, $text1_lay, $text2_lay, 110.0, $elev, $depth, 0, 0, 0, 0, 0, 0, 0);
  47.     $text2_lay->invert;
  48.     $img->lower_layer($text2_lay);
  49.     $text2_lay->translate(2, 3);
  50.     $text2_lay->set_opacity(75);
  51.     if ($rad_tog == 1) {
  52.         $img->flatten;
  53.         gimp_convert_indexed ($img, 0, MAKE_PALETTE, 256, 0, 0, "");
  54.             my $new = gimp_image_active_drawable ($img);
  55.             gimp_layer_add_alpha ($new);
  56.             gimp_by_color_select ($new, [255, 255, 255], 55, ADD, 0, 0, 0.0, 0);
  57.             gimp_edit_clear ($new);
  58.             gimp_selection_none ($img);
  59.         } else {
  60.         $img->flatten;
  61.     }
  62.     gimp_display_new ($img);
  63.     exit main;
  64. }
  65. $help=<<EOF.$help;
  66. This script will produce a nice blended beveled logo from your alpha
  67. layer, which must have a black text. You can choose the initial and finals colours
  68. of the blend, the background, and how to tweak the bevel effect.
  69. It uses a techinque quite similar to that in the Inner Bevel Logo.
  70.  
  71. EOF
  72.  
  73. register "make_bevel_logos",
  74.          "A script to get blended beveled logos",
  75.          $help,
  76.          "Michele Gherlone <mikem\@enet.it>",
  77.          "(c) 2000 M. Gherlone",
  78.          "20000130",
  79.          N_"<Image>/Filters/Logulator/Blended II...",
  80.          "*",
  81.          [
  82.            [PF_COLOUR    , 'choose_bg_colour', "Choose the background colour", [255, 255, 255]],
  83.            [PF_COLOUR    , 'blend_start',  "Choose the 1st blend colour", [247, 231, 9]],
  84.            [PF_COLOUR    , 'blend_stop',   "Choose the 2nd blend colour", [255, 0, 0]],
  85.            [PF_SLIDER    , 'strength_of_bevel', "Strength of bevel", 45.00, [0.00, 60.00, 0.50]],
  86.            [PF_SLIDER    , 'depth_of_bevel', "Depth of bevel", 4, [0, 60, 1]],
  87.            [PF_RADIO    , 'user_choice', "The user's choice", 0, [Background => 0, Transparent => 1]],
  88.          ],
  89.          \&my_innerbevel;
  90. exit main;
  91.  
  92.